﻿@model IEnumerable<TestSys.Models.groups>
@{
    ViewBag.Title = "ManageGroups";
    Layout = "~/Views/Admin/_AdminLayout.cshtml";
}

<script type="text/javascript">
    function destroy(ID) {
        if (confirm("Deleting this groupe will result into deleting all users attached to the group! Sure?")) {
            var url = '@Url.Action("DeleteGroup","Admin")';
            url += '/' + ID;
            location.href = url;
        }
    }
    function create() {
        var url = '@Url.Action("CreateGroup","Admin")';
        location.href = url;
    }

</script>

<h2>ManageGroups</h2>

<h4>@Html.ValidationSummary(true)</h4>

<table id = "manageTable" rules="groups">
<colgroup span=4 />
<colgroup span=1 />
<tr>
    <th>Name</th>
</tr>
@foreach (var item in Model)
{
    <tr>
        <td>@item.GroupName</td>
        <td>@Html.ActionLink("Edit", "EditGroup", "Admin", new { id = item.GroupID }, null)</td>
        <td>Future Users Adding (=</td>
        <td>Future Tests Adding (=</td>
        <td><p onclick="destroy('@item.GroupID')">-</p></td>
    </tr>
}
</table>
<div id="CreateLnk">
    <input type="button" value="Create new group" onclick="create()" />
</div>